﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Classes.sim {
    import Engine.Helpers.*;
    import flash.utils.*;
    import Classes.*;
    import Modules.quest.Managers.*;
    import Modules.stats.experiments.*;
    import Classes.MiniQuest.*;

    public class MiniQuestManager implements IGameWorldUpdateObserver {

        protected static var m_giftsSkipped:Boolean = false;

        private var m_world:GameWorld;
        private var m_miniQuests:Dictionary;
        private var m_lastQuestLog:Number;
        private var m_lastFranchiseLog:Number;
        private var m_lastHeadquarterInventoryLog:Number;
        private var m_lastDailyBonusLog:Number;
        private var m_lastPendingFranchiseLog:Number;

        public function MiniQuestManager(_arg1:GameWorld){
            this.m_world = _arg1;
            _arg1.addObserver(this);
            this.m_miniQuests = new Dictionary();
        }
        public static function set giftsSkipped(_arg1:Boolean):void{
            m_giftsSkipped = _arg1;
        }

        public function initialize():void{
            this.m_lastQuestLog = 0;
            this.m_lastFranchiseLog = 0;
            this.m_lastHeadquarterInventoryLog = 60;
            this.m_lastDailyBonusLog = 0;
            this.m_lastPendingFranchiseLog = 0;
        }
        public function resetPendingFranchiseLog():void{
            this.m_lastPendingFranchiseLog = 0;
        }
        public function cleanUp():void{
        }
        public function onGameLoaded(_arg1:Object):void{
            this.m_miniQuests[FranchiseSaleMQ.QUEST_NAME] = new FranchiseSaleMQ();
            this.m_miniQuests[HeadquarterInventoryMQ.QUEST_NAME] = new HeadquarterInventoryMQ();
            this.m_miniQuests[DailyBonusMQ.QUEST_NAME] = new DailyBonusMQ();
            this.m_miniQuests[GiftMQ.QUEST_NAME] = new GiftMQ();
            this.m_miniQuests[RequestItemMQ.QUEST_NAME] = new RequestItemMQ();
            this.m_miniQuests[PendingFranchiseMQ.QUEST_NAME] = new PendingFranchiseMQ();
            this.m_miniQuests[ZooDonationMQ.QUEST_NAME] = new ZooDonationMQ();
        }
        public function onResourceChange(_arg1:MapResource, _arg2:Vector3, _arg3:Vector3):void{
        }
        public function update(_arg1:Number):void{
            var _local3:int;
            var _local4:int;
            if (_arg1){
                this.m_lastQuestLog = (this.m_lastQuestLog + _arg1);
                this.m_lastFranchiseLog = (this.m_lastFranchiseLog + _arg1);
                this.m_lastHeadquarterInventoryLog = (this.m_lastHeadquarterInventoryLog + _arg1);
                this.m_lastDailyBonusLog = (this.m_lastDailyBonusLog + _arg1);
                this.m_lastPendingFranchiseLog = (this.m_lastPendingFranchiseLog + _arg1);
            };
            if (((((this.m_miniQuests[FranchiseSaleMQ.QUEST_NAME]) && (this.m_miniQuests[FranchiseSaleMQ.QUEST_NAME].recurrenceTime))) && (Global.questManager.isFlagReached(GameQuestManager.QUEST_UX_SUPPLY_MQ_UNLOCKED)))){
                if (this.m_lastFranchiseLog > this.m_miniQuests[FranchiseSaleMQ.QUEST_NAME].recurrenceTime){
                    this.m_miniQuests[FranchiseSaleMQ.QUEST_NAME].checkFranchiseSales();
                    if (this.m_miniQuests[FranchiseSaleMQ.QUEST_NAME].needSaleCount){
                        this.m_miniQuests[FranchiseSaleMQ.QUEST_NAME].toggleMiniQuest(true);
                    };
                    this.m_lastFranchiseLog = 0;
                };
            };
            if (((((this.m_miniQuests[HeadquarterInventoryMQ.QUEST_NAME]) && (this.m_miniQuests[HeadquarterInventoryMQ.QUEST_NAME].recurrenceTime))) && (Global.questManager.isFlagReached(GameQuestManager.QUEST_UX_HQ_MQ_UNLOCKED)))){
                if (this.m_lastHeadquarterInventoryLog > this.m_miniQuests[HeadquarterInventoryMQ.QUEST_NAME].recurrenceTime){
                    if (this.m_miniQuests[HeadquarterInventoryMQ.QUEST_NAME].isQuestNeeded){
                        this.m_miniQuests[HeadquarterInventoryMQ.QUEST_NAME].toggleMiniQuest(true);
                    };
                    this.m_lastHeadquarterInventoryLog = 0;
                };
            };
            var _local2:int = Global.experimentManager.getVariant(ExperimentDefinitions.EXPERIMENT_DAILY_BONUS_AUTOPOP);
            if (_local2 < ExperimentDefinitions.DAILY_BONUS_AUTOPOP_ON){
                if (((((this.m_miniQuests[DailyBonusMQ.QUEST_NAME]) && (this.m_miniQuests[DailyBonusMQ.QUEST_NAME].recurrenceTime))) && (Global.questManager.isFlagReached(GameQuestManager.QUEST_UX_VISITS_UNLOCKED)))){
                    if (this.m_lastDailyBonusLog > this.m_miniQuests[DailyBonusMQ.QUEST_NAME].recurrenceTime){
                        if (((Global.player.dailyBonusManager.isBonusAvailable) && (!(Global.player.isNewPlayer)))){
                            this.m_miniQuests[DailyBonusMQ.QUEST_NAME].toggleMiniQuest(true);
                        };
                        this.m_lastDailyBonusLog = 0;
                    };
                };
            };
            if (((((((((((this.m_miniQuests[GiftMQ.QUEST_NAME]) && (!(Global.isVisiting())))) && (!(Global.guide.isActive())))) && (Global.questManager.isFlagReached(GameQuestManager.QUEST_UX_VISITS_UNLOCKED)))) && (!(Global.player.isFirstDay)))) && (!(MiniQuestManager.m_giftsSkipped)))){
                _local3 = (GlobalEngine.getTimer() / 1000);
                _local4 = Global.player.getLastActivationTime(this.m_miniQuests[GiftMQ.QUEST_NAME].miniQuestName);
                if (((((_local4 - _local3) >= Global.gameSettings.inGameDaySeconds)) || ((_local4 == -1)))){
                    this.m_miniQuests[GiftMQ.QUEST_NAME].toggleMiniQuest(true);
                };
            };
            if (this.m_miniQuests[RequestItemMQ.QUEST_NAME]){
                if (this.m_miniQuests[RequestItemMQ.QUEST_NAME].isQuestNeeded){
                    this.m_miniQuests[RequestItemMQ.QUEST_NAME].toggleMiniQuest(true);
                };
            };
            if (this.m_miniQuests[PendingFranchiseMQ.QUEST_NAME]){
                if ((((this.m_lastPendingFranchiseLog > this.m_miniQuests[PendingFranchiseMQ.QUEST_NAME].recurrenceTime)) && ((this.m_miniQuests[PendingFranchiseMQ.QUEST_NAME].recurrenceTime > 0)))){
                    if (this.m_miniQuests[PendingFranchiseMQ.QUEST_NAME].isQuestNeeded){
                        this.m_miniQuests[PendingFranchiseMQ.QUEST_NAME].toggleMiniQuest(true);
                    };
                };
            };
            if (((((this.m_miniQuests[ZooDonationMQ.QUEST_NAME]) && (this.m_miniQuests[ZooDonationMQ.QUEST_NAME].isQuestNeeded))) && (this.m_miniQuests[ZooDonationMQ.QUEST_NAME].recurrenceTime))){
                this.m_miniQuests[ZooDonationMQ.QUEST_NAME].toggleMiniQuest(true);
            };
        }
        public function endMiniQuest(_arg1:String):void{
            if (this.m_miniQuests.hasOwnProperty(_arg1)){
                this.m_miniQuests[_arg1].deactivate();
            };
        }

    }
}//package Classes.sim 
